<template>
  <div>
    <h4>欢迎光临vue开发的收银系统</h4>
    <table border="1">
      <thead>
        <tr>
          <th>苹果￥10/斤，现折扣 《8折》 </th>
        </tr>
      </thead>
      <tbody>
        <tr>
          请输入你需要购买的数量 <input v-model.number="prices" type="text" value="">斤数
        </tr>
        <tr><button type="button" @click="buyFn">结账</button></tr>
        <tr>结账单：总价<span v-text="totalPrices"></span> 元，折后价<span v-text="discountPrice"></span> 元；省了<span v-text="num"></span> 元</tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  data(){
    return{
      prices:0,
      totalPrices:'',
      discountPrice:'',
      num:''
    }
  },
  methods:{
    buyFn(){
      console.log(1)
      this.totalPrices=parseFloat(this.prices)*10
      this.discountPrice=parseFloat(this.prices)*8
      this.num=parseFloat(this.prices)*2
    }
  }
}
</script>

<style>
h4{

  padding-left :43% ;
}
table{
  width: 500px;
  height: 150px;
  text-align: center;
  margin: 0 auto;
}

</style>